package com.whj.servicemap.service.impl;

import com.whj.internalcommon.dto.ResponseResult;
import com.whj.internalcommon.response.DirectionResponse;
import com.whj.servicemap.remote.MapDirectionClient;
import com.whj.servicemap.service.DirectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: wanghaijun
 * @Date: 2023/1/6 - 01 - 06 - 14:24 
 * @Description: com.whj.servicemap.service.impl
 */

@Service
public class DirectionServiceImpl implements DirectionService {

    @Autowired
    private MapDirectionClient mapDirectionClient;

    /**
     * 根据起点和终点经纬度获取距离（米）和时长（分钟）
     *
     * @param depLongitude
     * @param depLatitude
     * @param desLongitude
     * @param desLatitude
     * @return
     */
    @Override
    public ResponseResult driving(String depLongitude, String depLatitude, String desLongitude, String desLatitude) {

        //调用第三方地图接口
        DirectionResponse directionResponse = mapDirectionClient.direction(depLongitude, depLatitude, desLongitude, desLatitude);
        return ResponseResult.success(directionResponse);
    }
}
